package idiet.service;

import java.util.List;

import idiet.bean.Unit;
import idiet.dao.hibernate.UnitDao;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository("unitService")
public class UnitService {
	@Autowired
	UnitDao unitDao;
	public Unit getUnitById(int unitId){
		return this.unitDao.getUnitById(unitId);
	}
	public List<Unit> getUnitsByUnitName(String unitName){
		if(unitName==null){
			return this.unitDao.getUnits();
		}else{
			return this.unitDao.getUnitsByUnitName(unitName);
		}
	}
	public void createUnit(Unit unit){
		this.unitDao.createUnit(unit);
	}
	public void updateUnit(Unit unit){
		this.unitDao.updateUnit(unit);
	}
	public void deleteUnit(Unit unit){
		this.unitDao.deleteUnit(unit);
	}
}
